<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        let baseUrl = 'http://localhost:3000'
        let options = ['/getData1', '/getData2', '/getData3']
        let res
        req(options[0]).then(p => {
            res = p
        })
        options.slice(1).forEach( async item => {
            res = await req(item, res)
        })
        console.log(res);
        function req(url, param) {
            return new Promise((resolve, reject) => {
                let xhr = new XMLHttpRequest()
                // xhr.timeout = 4000
                xhr.open('get',baseUrl + url, true)
                xhr.onreadystatechange = function () {
                    if (xhr.readystate === 4) {
                        if (xhr.status === 200 || xhr.status === 0) {
                            resolve(xhr.responseText)
                        }
                        else {
                            reject('fail')
                        }
                    }
                }
                xhr.send()
            })
        }
    </script>
</body>
</html>